#include "Model3D.h"

Model3D::Model3D()
{
}

//funcion que recibe el umbral y la intensidad en dos puntos y realiza la interpolacion
double interpolatePoints(double umbral, double v1, double v2){
	if(v1==v2)
		return v1;

	double interpolatePoint = 1.0 -(umbral-v2)/(v1-v2);
	return interpolatePoint;
}


//Insertar nuevo triangulo en el vector de triangulos.
void Model3D::insertTriangle(Triangle newTriangle){
	_triangles.push_back(newTriangle);

}


std::vector <Triangle>  Model3D::getTriangles(){
	return _triangles;
}

Triangle Model3D::getTriangle(int i){
	return _triangles[i];
}
/****************************************************************************************************
Funcion que a partir del caso base, calcula el voxel final teniendo en cuenta la rotación realizada previamente.
****************************************************************************************************/
void Model3D::addTriangles(int casoBase, Cube rotatedCube, int rotx, int roty, int rotz,float umbral)
{
	std::vector<Point> possibleIntersectionPoints;
	possibleIntersectionPoints=calculateInterpolated12Points(rotatedCube,  umbral);
	//Switch con las 15 llamadas a funciones segun caso base.
	int ijk [3] = {rotatedCube.getInitialVertex()[0], rotatedCube.getInitialVertex()[1], rotatedCube.getInitialVertex()[2]};
	switch(casoBase)
	{
	case 0:break;
	case 1:
		addTrianglesCasoBase1(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 2:
		addTrianglesCasoBase2(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 3:
		addTrianglesCasoBase3(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 4:
		addTrianglesCasoBase4(possibleIntersectionPoints,rotx,roty,rotz,ijk );
		break;
	case 5:
		addTrianglesCasoBase5(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 6:
		addTrianglesCasoBase6(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 7:
		addTrianglesCasoBase7(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 8:
		addTrianglesCasoBase8(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 9:
		addTrianglesCasoBase9(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 10:
		addTrianglesCasoBase10(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 11:
		addTrianglesCasoBase11(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 12:
		addTrianglesCasoBase12(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 13:
		addTrianglesCasoBase13(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	case 14:
		addTrianglesCasoBase14(possibleIntersectionPoints,rotx,roty,rotz, ijk);
		break;
	}
}


//cacula todos los puntos de interseccionposibles que pueden formar los triangulos
std::vector<Point> Model3D::calculateInterpolated12Points(Cube cube, double umbral){
	std::vector<Point> possibleIntersectionPoints;
	double interpolatedPoint1=interpolatePoints(umbral,cube.getVertex(0),cube.getVertex(1));
	double interpolatedPoint2=interpolatePoints(umbral,cube.getVertex(1),cube.getVertex(2));
	double interpolatedPoint3=interpolatePoints(umbral,cube.getVertex(3), cube.getVertex(2));
	double interpolatedPoint4=interpolatePoints(umbral,cube.getVertex(0), cube.getVertex(3));
	double interpolatedPoint5=interpolatePoints(umbral,cube.getVertex(4),cube.getVertex(5));
	double interpolatedPoint6=interpolatePoints(umbral,cube.getVertex(5),cube.getVertex(6));
	double interpolatedPoint7=interpolatePoints(umbral,cube.getVertex(7), cube.getVertex(6));
	double interpolatedPoint8=interpolatePoints(umbral,cube.getVertex(4), cube.getVertex(7));
	double interpolatedPoint9=interpolatePoints(umbral,cube.getVertex(0),cube.getVertex(4));
	double interpolatedPoint10=interpolatePoints(umbral,cube.getVertex(1),cube.getVertex(5));
	double interpolatedPoint11=interpolatePoints(umbral,cube.getVertex(2),cube.getVertex(6));
	double interpolatedPoint12=interpolatePoints(umbral,cube.getVertex(3),cube.getVertex(7));
	possibleIntersectionPoints.push_back(Point(interpolatedPoint1,0,0));
	possibleIntersectionPoints.push_back(Point(1,interpolatedPoint2,0));
	possibleIntersectionPoints.push_back(Point(interpolatedPoint3,1,0));
	possibleIntersectionPoints.push_back(Point(0,interpolatedPoint4,0));
	possibleIntersectionPoints.push_back(Point(interpolatedPoint5,0,1));
	possibleIntersectionPoints.push_back(Point(1,interpolatedPoint6,1));
	possibleIntersectionPoints.push_back(Point(interpolatedPoint7,1,1));
	possibleIntersectionPoints.push_back(Point(0,interpolatedPoint8,1));
	possibleIntersectionPoints.push_back(Point(0,0,interpolatedPoint9));
	possibleIntersectionPoints.push_back(Point(1,0,interpolatedPoint10));
	possibleIntersectionPoints.push_back(Point(1,1,interpolatedPoint11));
	possibleIntersectionPoints.push_back(Point(0,1,interpolatedPoint12));
	return possibleIntersectionPoints;
}
/**************************************************************************
 Funciones que calculan el voxel dependiendo del caso base
 ***************************************************************************/
//caso base 1
void Model3D::addTrianglesCasoBase1(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[0],possibleIntersectionPoints[8],possibleIntersectionPoints[3]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle,1 + _lastIndex ,2 + _lastIndex ,3 + _lastIndex);
	insertTriangle(newTriangle);

	}

//caso base 2
void Model3D::addTrianglesCasoBase2(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[1],possibleIntersectionPoints[3],possibleIntersectionPoints[9]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle,1 + _lastIndex, 2 + _lastIndex, 3+ _lastIndex);
	insertTriangle(newTriangle);

	Triangle newTriangle2(possibleIntersectionPoints[8],possibleIntersectionPoints[9],possibleIntersectionPoints[3]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2, 4 + _lastIndex, 3 + _lastIndex, 2 + _lastIndex);
	insertTriangle(newTriangle2);

	}

//caso base 3
void Model3D::addTrianglesCasoBase3(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz , int * ijk ){

	Triangle newTriangle(possibleIntersectionPoints[0],possibleIntersectionPoints[8],possibleIntersectionPoints[3]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle, 1 + _lastIndex, 2+ _lastIndex, 3 + _lastIndex);
	insertTriangle(newTriangle);

	Triangle newTriangle2(possibleIntersectionPoints[9],possibleIntersectionPoints[4],possibleIntersectionPoints[5]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2, 4 + _lastIndex, 5 + _lastIndex, 6 + _lastIndex);
	insertTriangle(newTriangle2);
	}

//caso base 4
void Model3D::addTrianglesCasoBase4(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz , int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[0],possibleIntersectionPoints[8],possibleIntersectionPoints[3]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle, 1 + _lastIndex,2 + _lastIndex,3 + _lastIndex);
	insertTriangle(newTriangle);

	Triangle newTriangle2(possibleIntersectionPoints[10],possibleIntersectionPoints[5],possibleIntersectionPoints[6]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2,4 + _lastIndex ,5 + _lastIndex ,6 + _lastIndex);
	insertTriangle(newTriangle2);

	}

//caso base 5
void Model3D::addTrianglesCasoBase5(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[0],possibleIntersectionPoints[3],possibleIntersectionPoints[9]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle, 1 + _lastIndex, 2 + _lastIndex, 3 + _lastIndex );
	insertTriangle(newTriangle);

	Triangle newTriangle2(possibleIntersectionPoints[3],possibleIntersectionPoints[11],possibleIntersectionPoints[9]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2, 2 + _lastIndex, 4 + _lastIndex,3 + _lastIndex);
	insertTriangle(newTriangle2);

	Triangle  newTriangle3(possibleIntersectionPoints[9],possibleIntersectionPoints[11],possibleIntersectionPoints[10]);

	newTriangle3.rotateTriangle(rotx,roty,rotz);
	newTriangle3.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle3,3 + _lastIndex ,4 + _lastIndex ,5 + _lastIndex);
	insertTriangle(newTriangle3);

	}

//caso base 6
void Model3D::addTrianglesCasoBase6(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[8],possibleIntersectionPoints[9],possibleIntersectionPoints[3]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle,1 + _lastIndex ,2 + _lastIndex ,3 + _lastIndex);
	insertTriangle(newTriangle);

	Triangle newTriangle2(possibleIntersectionPoints[10],possibleIntersectionPoints[5],possibleIntersectionPoints[6]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2,4 + _lastIndex ,5 + _lastIndex, 6 + _lastIndex);
	insertTriangle(newTriangle2);

	Triangle newTriangle3(possibleIntersectionPoints[3],possibleIntersectionPoints[1],possibleIntersectionPoints[9]);

	newTriangle3.rotateTriangle(rotx,roty,rotz);
	newTriangle3.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle3, 3 + _lastIndex, 7 + _lastIndex, 2 + _lastIndex);
	insertTriangle(newTriangle3);

	}

//caso base 7
void Model3D::addTrianglesCasoBase7(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[8],possibleIntersectionPoints[4],possibleIntersectionPoints[7]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle,1 + _lastIndex, 2 + _lastIndex, 3 + _lastIndex);
	insertTriangle(newTriangle);

	Triangle newTriangle2(possibleIntersectionPoints[10],possibleIntersectionPoints[5],possibleIntersectionPoints[6]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2, 4 + _lastIndex, 5 + _lastIndex, 6 + _lastIndex);
	insertTriangle(newTriangle2);

	Triangle newTriangle3(possibleIntersectionPoints[0],possibleIntersectionPoints[1],possibleIntersectionPoints[9]);

	newTriangle3.rotateTriangle(rotx,roty,rotz);
	newTriangle3.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle3, 7 + _lastIndex, 8 + _lastIndex, 9+ _lastIndex);
	insertTriangle(newTriangle3);

	}

//caso base 8
void Model3D::addTrianglesCasoBase8(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[8],possibleIntersectionPoints[9],possibleIntersectionPoints[10]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle, 1+ _lastIndex, 2 + _lastIndex, 3 + _lastIndex);
	insertTriangle(newTriangle);

	Triangle newTriangle2(possibleIntersectionPoints[10],possibleIntersectionPoints[11],possibleIntersectionPoints[8]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2, 3 + _lastIndex, 4 + _lastIndex, 1 + _lastIndex);
	insertTriangle(newTriangle2);

	}

//caso base 9
void Model3D::addTrianglesCasoBase9(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[0],possibleIntersectionPoints[1],possibleIntersectionPoints[10]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
//	insertTriangle(newTriangle, 1 + _lastIndex, 2 + _lastIndex, 3 + _lastIndex);

	insertTriangle(newTriangle);

	Triangle newTriangle2(possibleIntersectionPoints[0],possibleIntersectionPoints[10],possibleIntersectionPoints[6]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2, 1 + _lastIndex, 3 + _lastIndex, 4 + _lastIndex);
	insertTriangle(newTriangle2)
	;
	Triangle newTriangle3(possibleIntersectionPoints[0],possibleIntersectionPoints[8],possibleIntersectionPoints[6]);

	newTriangle3.rotateTriangle(rotx,roty,rotz);
	newTriangle3.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle3, 1 + _lastIndex, 5 + _lastIndex, 4 + _lastIndex);
	insertTriangle(newTriangle3);

	Triangle newTriangle4(possibleIntersectionPoints[8],possibleIntersectionPoints[6],possibleIntersectionPoints[7]);

	newTriangle4.rotateTriangle(rotx,roty,rotz);
	newTriangle4.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle4, 5 + _lastIndex, 4 + _lastIndex, 6 + _lastIndex);
	insertTriangle(newTriangle4);
	}

//caso base 10
void Model3D::addTrianglesCasoBase10(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[4],possibleIntersectionPoints[3],possibleIntersectionPoints[7]);
//*****
	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle, 1 + _lastIndex, 2 + _lastIndex, 3 + _lastIndex );
	insertTriangle(newTriangle);

	Triangle newTriangle2(possibleIntersectionPoints[0],possibleIntersectionPoints[3],possibleIntersectionPoints[4]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2, 1 + _lastIndex, 2 + _lastIndex , 4 + _lastIndex);
	insertTriangle(newTriangle2);

	Triangle newTriangle3(possibleIntersectionPoints[1],possibleIntersectionPoints[5],possibleIntersectionPoints[2]);

	newTriangle3.rotateTriangle(rotx,roty,rotz);
	newTriangle3.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle3, 5 + _lastIndex, 6 + _lastIndex, 7 + _lastIndex);
	insertTriangle(newTriangle3);

	Triangle newTriangle4(possibleIntersectionPoints[5],possibleIntersectionPoints[2],possibleIntersectionPoints[6]);

	newTriangle4.rotateTriangle(rotx,roty,rotz);
	newTriangle4.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle4, 5 + _lastIndex, 6 + _lastIndex, 8+ _lastIndex);
	insertTriangle(newTriangle4);

	}

//caso base 11
void Model3D::addTrianglesCasoBase11(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[0],possibleIntersectionPoints[1],possibleIntersectionPoints[5]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle, 1 + _lastIndex, 2 + _lastIndex , 3 + _lastIndex);
	insertTriangle(newTriangle);

	Triangle newTriangle2(possibleIntersectionPoints[0],possibleIntersectionPoints[8],possibleIntersectionPoints[11]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2,1 + _lastIndex , 4 + _lastIndex , 5 + _lastIndex);
	insertTriangle(newTriangle2);
	Triangle newTriangle3(possibleIntersectionPoints[11],possibleIntersectionPoints[6],possibleIntersectionPoints[5]);

	newTriangle3.rotateTriangle(rotx,roty,rotz);
	newTriangle3.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle3, 5+ _lastIndex ,6 + _lastIndex ,3  + _lastIndex);
	insertTriangle(newTriangle3);

	Triangle newTriangle4(possibleIntersectionPoints[0],possibleIntersectionPoints[5],possibleIntersectionPoints[11]);

	newTriangle4.rotateTriangle(rotx,roty,rotz);
	newTriangle4.trasladar(ijk[0], ijk[1] , ijk[2]);
//	insertTriangle(newTriangle4,1 + _lastIndex ,3 + _lastIndex ,5 + _lastIndex);
	insertTriangle(newTriangle4);
	}

//caso base 12
void Model3D::addTrianglesCasoBase12(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[8],possibleIntersectionPoints[4],possibleIntersectionPoints[7]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle, 1 + _lastIndex , 2 + _lastIndex , 3 + _lastIndex);
	insertTriangle(newTriangle);

	Triangle newTriangle2(possibleIntersectionPoints[0],possibleIntersectionPoints[3],possibleIntersectionPoints[9]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2, 4+ _lastIndex ,5 + _lastIndex ,6+ _lastIndex);
	insertTriangle(newTriangle2);

	Triangle newTriangle3(possibleIntersectionPoints[3],possibleIntersectionPoints[9],possibleIntersectionPoints[11]);

	newTriangle3.rotateTriangle(rotx,roty,rotz);
	newTriangle3.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle3, 5+ _lastIndex ,6 + _lastIndex ,7 + _lastIndex);
	insertTriangle(newTriangle3);
	Triangle newTriangle4(possibleIntersectionPoints[9],possibleIntersectionPoints[10],possibleIntersectionPoints[11]);

	newTriangle4.rotateTriangle(rotx,roty,rotz);
	newTriangle4.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle4,6 + _lastIndex ,8 + _lastIndex ,7 + _lastIndex);
	insertTriangle(newTriangle4);
	}

//caso base 13
void Model3D::addTrianglesCasoBase13(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[0],possibleIntersectionPoints[3],possibleIntersectionPoints[8]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
//	insertTriangle(newTriangle,1 + _lastIndex ,2 + _lastIndex ,3 + _lastIndex);
	insertTriangle(newTriangle);
	Triangle newTriangle2(possibleIntersectionPoints[1],possibleIntersectionPoints[2],possibleIntersectionPoints[10]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2, 4 + _lastIndex , 5 + _lastIndex , 6 + _lastIndex);
	insertTriangle(newTriangle2);

	Triangle newTriangle3(possibleIntersectionPoints[9],possibleIntersectionPoints[4],possibleIntersectionPoints[5]);

	newTriangle3.rotateTriangle(rotx,roty,rotz);
	newTriangle3.trasladar(ijk[0], ijk[1] , ijk[2]);
//	insertTriangle(newTriangle3, 5 + _lastIndex, 7 + _lastIndex, 8 + _lastIndex);
	insertTriangle(newTriangle3);

	Triangle newTriangle4(possibleIntersectionPoints[7],possibleIntersectionPoints[6],possibleIntersectionPoints[11]);

	newTriangle4.rotateTriangle(rotx,roty,rotz);
	newTriangle4.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle4, 9 + _lastIndex, 10 + _lastIndex, 11 + _lastIndex);
	insertTriangle(newTriangle4);
	}

//caso base 14
void Model3D::addTrianglesCasoBase14(std::vector<Point> possibleIntersectionPoints, int rotx, int roty, int rotz, int * ijk ){
	Triangle newTriangle(possibleIntersectionPoints[0],possibleIntersectionPoints[3],possibleIntersectionPoints[7]);

	newTriangle.rotateTriangle(rotx,roty,rotz);
	newTriangle.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle, 1 + _lastIndex, 2 + _lastIndex, 3 + _lastIndex);
	insertTriangle(newTriangle);
	Triangle newTriangle2(possibleIntersectionPoints[0],possibleIntersectionPoints[9],possibleIntersectionPoints[10]);

	newTriangle2.rotateTriangle(rotx,roty,rotz);
	newTriangle2.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle2, 1 + _lastIndex, 4 + _lastIndex, 5 + _lastIndex);
	insertTriangle(newTriangle2);

	Triangle newTriangle3(possibleIntersectionPoints[0],possibleIntersectionPoints[10],possibleIntersectionPoints[7]);

	newTriangle3.rotateTriangle(rotx,roty,rotz);
	newTriangle3.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle3,1 + _lastIndex, 5 + _lastIndex, 3+ _lastIndex);
	insertTriangle(newTriangle3);

	Triangle newTriangle4(possibleIntersectionPoints[6],possibleIntersectionPoints[7],possibleIntersectionPoints[10]);

	newTriangle4.rotateTriangle(rotx,roty,rotz);
	newTriangle4.trasladar(ijk[0], ijk[1] , ijk[2]);
	//insertTriangle(newTriangle4, 6 +_lastIndex, 3 + _lastIndex,5 + _lastIndex);
	insertTriangle(newTriangle4);
	}


